package com.zmn.plat.services.impl.contract.record;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.contract.record.ContractRecord;
import com.zmn.plat.model.entity.contract.record.ContractRecordQuery;
import com.zmn.plat.model.vo.contract.record.ContractRecordVO;
import com.zmn.plat.persistence.interfaces.contract.record.ContractRecordDao;
import com.zmn.plat.services.interfaces.contract.record.ContractRecordService;

@Service
public class ContractRecordServiceImpl implements ContractRecordService {

    @Resource
    ContractRecordDao contractRecordDao;

    @Override
    public ContractRecord findByKey(Integer contractId) {
        return contractRecordDao.findByKey(contractId);
    }

    @Override
    public Integer findMaxSort() {
        return contractRecordDao.findMaxSort();
    }

    @Override
    public List<ContractRecordVO> listPageByQuery(ContractRecordQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return contractRecordDao.listPageByQuery(query);
    }

    @Override
    public List<ContractRecord> listByQuery(ContractRecordQuery query) {
        return contractRecordDao.listByQuery(query);
    }

    @Override
    public List<ContractRecord> listAll() {
        return contractRecordDao.listAll();
    }

    @Override
    public Integer countByQuery(ContractRecordQuery query) {
        return contractRecordDao.countByQuery(query);
    }

    @Override
    public Integer updateStatusByKey(ContractRecord contractRecord) {
        return contractRecordDao.updateStatusByKey(contractRecord);
    }

    @Override
    public Integer updateStatusBatchByKey(List<Integer> ids, Integer status, String mcStaffName) {
        return contractRecordDao.updateBatchStatusByKey(ids, status, mcStaffName);
    }

    @Override
    public Integer updateByKey(ContractRecord contractRecord) {
        return contractRecordDao.updateByKey(contractRecord);
    }

    @Override
    public Integer updateSortByKey(Integer contractId, Integer sort, String mcStaffName) {
        ContractRecord contractRecord = new ContractRecord();
        contractRecord.setContractId(contractId);
        contractRecord.setSort(sort);
        contractRecord.setUpdater(mcStaffName);

        return contractRecordDao.updateSortByKey(contractRecord);
    }

    @Override
    public Integer insert(ContractRecord contractRecord) {
        return contractRecordDao.insert(contractRecord);
    }

    @Override
    public Integer deleteByKey(Integer contractId) {
        return contractRecordDao.deleteByKey(contractId);
    }
}